package com.moly.websocketone.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Description:  自定义过滤器
 * @Author: m01
 * @Date: created at  2018/11/13  14:55
 * @Modified By:
 */
public class TestFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

        System.out.println(" -- TestFilter doFilter -- ");
        HttpSession session = ((HttpServletRequest) servletRequest).getSession();
        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println(" -- TestFilter init -- ");

    }

    @Override
    public void destroy() {
        System.out.println(" --TestFilter destory -- ");
    }
}
